//
//  PdfMainVipView.m
#import "PdfMainVipView.h"
@interface PdfMainVipView()
@property (nonatomic,strong) UILabel *pdfMainVipNameLab;
@property (nonatomic,strong) UILabel *pdfMainVipTitleLab;
@property (nonatomic,strong) UIButton *pdfMainOpenVipBtn;
@end
@implementation PdfMainVipView
-(instancetype)init{
    if (self == [super init]) {
        [self creatPdfSubView];
    }
    return self;
}
- (void)creatPdfSubView{
    UIImageView * pdfMainVipImgBgView = [[UIImageView alloc] init];
    pdfMainVipImgBgView.userInteractionEnabled = true;
    pdfMainVipImgBgView.image = PdfImageNamed(@"pdfVipHeadBg");
    [self addSubview:pdfMainVipImgBgView];
    [pdfMainVipImgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(24)));
        make.right.equalTo(@(-PdfRatio(24)));
        make.top.equalTo(@(PdfRatio(0)));
        make.height.equalTo(@(PdfRatio(220)));
    }];
    self.pdfMainVipNameLab = [[UILabel alloc] init];
    self.pdfMainVipNameLab.textColor = PdfHex(@"#562D0B");
    self.pdfMainVipNameLab.font = [UIFont systemFontOfSize:PdfRatio(38) weight:UIFontWeightRegular];
    [pdfMainVipImgBgView addSubview:self.pdfMainVipNameLab];
    [self.pdfMainVipNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(31)));
        make.top.equalTo(@(PdfRatio(51)));
        make.height.equalTo(@(PdfRatio(50)));
    }];
    self.pdfMainVipTitleLab = [[UILabel alloc] init];
    self.pdfMainVipTitleLab.textColor = PdfHex(@"#562D0B");
    self.pdfMainVipTitleLab.font = [UIFont systemFontOfSize:PdfRatio(24) weight:UIFontWeightRegular];
    [pdfMainVipImgBgView addSubview:self.pdfMainVipTitleLab];
    [self.pdfMainVipTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(PdfRatio(31)));
        make.top.equalTo(self.pdfMainVipNameLab.mas_bottom).offset(PdfRatio(14));
        make.height.equalTo(@(PdfRatio(34)));
    }];
    self.pdfMainOpenVipBtn = [[UIButton alloc] init];
    [self.pdfMainOpenVipBtn setBackgroundImage:PdfImageNamed(@"pdfOpenVip") forState:UIControlStateNormal];
    [self.pdfMainOpenVipBtn addTarget:self action:@selector(pdfMainOpenVip) forControlEvents:UIControlEventTouchUpInside];
    [pdfMainVipImgBgView addSubview:self.pdfMainOpenVipBtn];
    [self.pdfMainOpenVipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-PdfRatio(47)));
        make.centerY.equalTo(pdfMainVipImgBgView);
        make.width.equalTo(@(PdfRatio(180)));
        make.height.equalTo(@(PdfRatio(62)));
    }];
    [self pdfUpdataVip];
}
- (void)pdfMainOpenVip{
    if(self.pdfMainOpenVipBlock){
        self.pdfMainOpenVipBlock();
    }
}
- (void)pdfUpdataVip{
//    if ([pdfHead ispdfVip]) {
//        self.pdfMainVipNameLab.text = @"你已是会员";
//        self.pdfMainOpenVipBtn.hidden = true;
//        
//        NSTimeInterval pdfVipBuyTime = (NSTimeInterval)[[NSUserDefaults standardUserDefaults] doubleForKey:@"pdfVipBuyTime"];
//        NSDate *pdfVipBuyTimeDate = [NSDate dateWithTimeIntervalSince1970:pdfVipBuyTime];
//        NSDateFormatter *pdfVipBuyTimeDateDateFormat = [[NSDateFormatter alloc] init];
//        [pdfVipBuyTimeDateDateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; // 设置日期格式
//        // 格式化日期并输出
//        NSString *pdfVipBuyTimeCurTime = [pdfVipBuyTimeDateDateFormat stringFromDate:pdfVipBuyTimeDate];
//        self.pdfMainVipTitleLab.text = [NSString stringWithFormat:@"会员有效期至:%@",pdfVipBuyTimeCurTime];
//    }else{
//        self.pdfMainVipNameLab.text = @"开通会员";
//        self.pdfMainVipTitleLab.text = @"享受所有会员权益  体验翻倍";
//        self.pdfMainOpenVipBtn.hidden = false;
//    }
}
@end
